<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>src\atom.js - GIAnT API</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.9.1/build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
    <link rel="icon" href="../assets/favicon.ico">
    <script src="http://yui.yahooapis.com/combo?3.9.1/build/yui/yui-min.js"></script>
</head>
<body class="yui3-skin-sam">

<div id="doc">
    <div id="hd" class="yui3-g header">
        <div class="yui3-u-3-4">
                <h1><img src="../assets/css/logo.png" title="GIAnT API" width="117" height="52"></h1>
        </div>
        <div class="yui3-u-1-4 version">
            <em>API Docs for: 1.0.0</em>
        </div>
    </div>
    <div id="bd" class="yui3-g">

        <div class="yui3-u-1-4">
            <div id="docs-sidebar" class="sidebar apidocs">
                <div id="api-list">
                    <h2 class="off-left">APIs</h2>
                    <div id="api-tabview" class="tabview">
                        <ul class="tabs">
                            <li><a href="#api-classes">Classes</a></li>
                            <li><a href="#api-modules">Modules</a></li>
                        </ul>
                
                        <div id="api-tabview-filter">
                            <input type="search" id="api-filter" placeholder="Type to filter APIs">
                        </div>
                
                        <div id="api-tabview-panel">
                            <ul id="api-classes" class="apis classes">
                                <li><a href="../classes/Atom.html">Atom</a></li>
                                <li><a href="../classes/Codec.html">Codec</a></li>
                                <li><a href="../classes/Constraints.html">Constraints</a></li>
                                <li><a href="../classes/Database.html">Database</a></li>
                                <li><a href="../classes/Exif.html">Exif</a></li>
                                <li><a href="../classes/Export.html">Export</a></li>
                                <li><a href="../classes/Heatmap.html">Heatmap</a></li>
                                <li><a href="../classes/Server.html">Server</a></li>
                                <li><a href="../classes/Settings.html">Settings</a></li>
                                <li><a href="../classes/Utils.html">Utils</a></li>
                            </ul>
                
                
                            <ul id="api-modules" class="apis modules">
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="yui3-u-3-4">
                <div id="api-options">
                    Show:
                    <label for="api-show-inherited">
                        <input type="checkbox" id="api-show-inherited" checked>
                        Inherited
                    </label>
            
                    <label for="api-show-protected">
                        <input type="checkbox" id="api-show-protected">
                        Protected
                    </label>
            
                    <label for="api-show-private">
                        <input type="checkbox" id="api-show-private">
                        Private
                    </label>
                    <label for="api-show-deprecated">
                        <input type="checkbox" id="api-show-deprecated">
                        Deprecated
                    </label>
            
                </div>
            
            <div class="apidocs">
                <div id="docs-main">
                    <div class="content">
<h1 class="file-heading">File: src\atom.js</h1>

<div class="file">
    <pre class="code prettyprint linenums">
/**
* The cross platform electron interface: This is the main entry file for the desktop application.
* &lt;br&gt;
* It controls: &lt;br&gt;
* 1) the electron app &lt;br&gt;
* 2) And the server &lt;br&gt;
*
* We use electron-log to write logs to the hard drive. Uncaught exceptions are finally caught here.
* &lt;br&gt;
* After creating the Electron Window, this file starts the SERVER!
*

* @class Atom
*/


var process = require(&#x27;process&#x27;);
var log = require(&#x27;electron-log&#x27;);

process.on(&#x27;uncaughtException&#x27;, function(err) {
  log.error((err &amp;&amp; err.stack) ? err.stack : err);
});

var server = require(&#x27;./server&#x27;);
var database = require(&#x27;./database&#x27;);

const {app, BrowserWindow} = require(&#x27;electron&#x27;);
const path = require(&#x27;path&#x27;);
const url = require(&#x27;url&#x27;);

// In this file you can include the rest of your app&#x27;s specific main process
// code. You can also put them in separate files and require them here.
log.info(app.getAppPath())

// var server = require(app.getAppPath() + &#x27;/src/server&#x27;);

// Keep a global reference of the window object, if you don&#x27;t, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;

function createWindow () {
  // Create the browser window.
  win = new BrowserWindow({width: 800, height: 600});
  log.info(&#x27;Electron window opened&#x27;);

  // and load the index.html of the app.
  win.loadURL(url.format({
    pathname: path.join(&#x27;localhost:4000&#x27;),
    protocol: &#x27;http:&#x27;,
    slashes: true
  }));

  // Open the DevTools.
  // win.webContents.openDevTools();

  // Emitted when the window is closed.
  win.on(&#x27;closed&#x27;, () =&gt; {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
      log.info(&#x27;window closed&#x27;);
      win = null
  })
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on(&#x27;ready&#x27;, createWindow)

// Quit when all windows are closed.
app.on(&#x27;window-all-closed&#x27;, () =&gt; {
  // On macOS it is common for applications and their menu bar
  // to stay active until the user quits explicitly with Cmd + Q
    log.info(&#x27;Electron windows closed&#x27;);
    database.logout();
    app.exit();
  //if (process.platform !== &#x27;darwin&#x27;) {
    //server.kill(&#x27;SIGINT&#x27;);
  //}
})

app.on(&#x27;activate&#x27;, () =&gt; {
  // On macOS it&#x27;s common to re-create a window in the app when the
  // dock icon is clicked and there are no other windows open.
  if (win === null) {
    createWindow()
  }
});

// Start the server
server.run();
    </pre>
</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>
<script src="../assets/js/yui-prettify.js"></script>
<script src="../assets/../api.js"></script>
<script src="../assets/js/api-filter.js"></script>
<script src="../assets/js/api-list.js"></script>
<script src="../assets/js/api-search.js"></script>
<script src="../assets/js/apidocs.js"></script>
</body>
</html>
